<%@page import="org.jeecgframework.web.util.StaticValue" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:1px;">
  <t:datagrid name="softwareVersionList" checkbox="true" fitColumns="false" sortName="createDate" sortOrder="desc" title="软件版本" onLoadSuccess="changeColor" actionUrl="softwareVersionController.do?datagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="软件名称"  field="sofeName"    queryMode="single"  width="120" query="true"></t:dgCol>
   <t:dgCol title="适用机型"  field="zyEsitemName"    queryMode="single"  width="120"  ></t:dgCol>
   <t:dgCol title="适用机型"  field="zyEsitem"  hidden="true"  queryMode="single"  width="120" query="true" ></t:dgCol>
   <t:dgCol title="软件版本"  field="version"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="更新说明"  field="versionExplain"    queryMode="single"  width="120"></t:dgCol>
   <t:dgCol title="发布时间"  field="createDate" formatter="yyyy-MM-dd" query="true"  queryMode="group"  width="120"></t:dgCol>
   <t:dgCol title="状态"  field="state"    queryMode="single"  width="120" query="true"  replace="已发布_1,已升级_2"></t:dgCol>
   <t:dgToolBar title="新建" icon="icon-add" url="softwareVersionController.do?goAdd" funname="add"></t:dgToolBar>
   <t:dgToolBar title="更新" icon="icon-edit" url="softwareVersionController.do?goUpdate" funname="update"></t:dgToolBar>
   <t:dgToolBar title="导出" icon="icon-putout" funname="ExportXls"></t:dgToolBar>
  </t:datagrid>
  </div>
 </div>
 <script src = "webpage/com/zybk/softwareversion/softwareVersionList.js"></script>
 <script type="text/javascript">
     /*$('#softwareVersionList').datagrid({
         rowStyler:function(index,row){
             if (row.state==1){
                 return 'color:red;';
             }
         }
     });*/
 $(document).ready(function(){
 		//给时间控件加上样式
 			$("#softwareVersionListtb").find("input[name='createDate_begin']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
 			$("#softwareVersionListtb").find("input[name='createDate_end']").attr("class","Wdate").attr("style","height:20px;width:90px;").click(function(){WdatePicker({dateFmt:'yyyy-MM-dd'});});
 });

//导出
function ExportXls() {
    var currPageRows = $("#softwareVersionList").datagrid("getRows");
    var idsData = [];
    $(currPageRows).each(function (i, rowData) {
        idsData.push(rowData.id);
    });
    if (idsData.length > 0) {
        myDownload("softwareVersionController.do?exportXls", "id=" + idsData.join(","));
    } else {
        tip("当前页面没有数据可以导出");
    }
}
function update(title,url,datagridName,width,height) {
    var datas = $("#softwareVersionList").datagrid("getSelections");
    if(datas.length != 1){
        tip("请选择一条信息");
        return;
    }
    var id = datas[0].id;
    var state = datas[0].state;
    if(state==2){
        tip("请选择最新版进行更新");
    }else{
        createwindow(title,url+"&id="+id,width,height);
        //location.href="softwareVersionController.do?goUpdate";
        /*$.dialog({
            content: "url:softwareVersionController.do?goUpdate&id="+id,
            zIndex: 10,
            title: '确认信息',
            lock: true,
            width: '700px',
            height: '400px',
            left: '50%',
            top: '50%',
            opacity: 0.4,
            init: function () {
                top.myWindow = window;
            },
            button: [{
                name: '确定',
                callback: function () {
                    iframe = this.iframe.contentWindow;
                    iframe.$('#formobj').submit();
                },
                focus: true
            }, {
                name: '关闭',
                callback: function () {
                }
            }]
        });*/
    }

}
/*已发布文字为红色*/
function changeColor() {
    var trs = $("#softwareVersionList").prev().find('div.datagrid-body').find('tr');
    for (var i = 0; i < trs.length; i++) {
        for (var j = 0; j < 8; j++) {
            if (trs[i].cells[j].firstChild.innerHTML =='已发布')
                trs[i].cells[j].style.cssText = 'color:red';
        }
    }
}
 $(function () {
     $('#zyEsitem').combotree({
         url: 'softwareVersionController.do?dataGridOfChooseEquipmentType',
         multiple: true,
     });
 })
 </script>